if(typeof window.screen.mozLockOrientation != "undefined") {
    window.screen.mozLockOrientation("portrait");
}

//Stop les événements 
function stop(event){
    event.stopPropagation();
    event.preventDefault();
}
                        
//Touch 
function touch(event){
    stop(event);
}

//Touch Start
function touchStart(event){
    stop(event);
        
    if(event.touches.length > 1)
        MOUSE.dbclic = true;
    else
        MOUSE.clic = true;
}

//Touch End
function touchEnd(event){
    stop(event);
    if(event.touches.length > 1)
        MOUSE.dbclic = false;
    else
        MOUSE.clic = false;
}

//Touch move
function touchMove(event){
    stop(event);
    
    MOUSE.x = event.touches[0].clientX;
    MOUSE.y = event.touches[0].clientY;
        
    MOUSE.clic = false;
}

//Accelerometer
function handleOrientation(event) {
    var gamma = event.gamma;
    var beta = event.beta;

    var newX = Math.round(game.p1.target.x) - Math.round(gamma);
    var newY = Math.round(game.p1.target.y) - Math.round(beta);

    if(game.p1.checkBoundary(newX,newY)){
        game.p1.target.x = newX;
        game.p1.target.y = newY;
    }
} 